package service.impl;

import dao.ScheduleDao;
import entity.Schedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import service.ScheduleService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("scheduleService")
public class ScheduleServiceImpl implements ScheduleService {


    @Autowired
    private ScheduleDao scheduleDao;

    @Override
    public List<Schedule> getToDay(long nId,String nName,String startTime, String endTime, int pageSize, int pageNumber) {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("nName",nName);
        map.put("nId",nId);
        map.put("startTime",startTime);
        map.put("endTime",endTime);
        map.put("offset",(pageNumber-1)*pageSize);
        map.put("limit",pageSize);
        return scheduleDao.getToDay(map);
    }

    @Override
    public List<Schedule> getTomorrow(String nName, String startTime, String endTime, int pageSize, int pageNumber) {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("nName",nName);
        map.put("startTime",startTime);
        map.put("endTime",endTime);
        map.put("offset",(pageNumber-1)*pageSize);
        map.put("limit",pageSize);
        return scheduleDao.getTomorrow(map);
    }

    @Override
    public List<Schedule> getNextWeek(String nName, String startTime, String endTime, int pageSize, int pageNumber) {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("nName",nName);
        map.put("startTime",startTime);
        map.put("endTime",endTime);
        map.put("offset",(pageNumber-1)*pageSize);
        map.put("limit",pageSize);
        return scheduleDao.getNextWeek(map);
    }

    @Override
    public List<Schedule> getAll(String nName, String startTime, String endTime, int pageSize, int pageNumber) {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("nName",nName);
        map.put("startTime",startTime);
        map.put("endTime",endTime);
        map.put("offset",(pageNumber-1)*pageSize);
        map.put("limit",pageSize);
        return scheduleDao.getAll(map);
    }
}
